
$(function(){
	$(".upload").hover(function(){
		$(".live_box").css({"opacity":"1"},{"display":"block"});
		// $(".live_items>a").hover(function(){
		// 	console.log(this)
		// 	$(this).css("color","#c6282").siblings("color","#fff")
		// },function(){
		// 	$(this).css("color","#fff")
		// })
	}
	,function(){
		$(".live_box").css("opacity","0")	
	})
	
	
	var lbt_list=[{src:"img/lb1.jpg",title:"咸菜鱼青衫_"},{src:"img/lb2.jpg",title:"可乐超酷"},
	{src:"img/lb3.png",title:"七月Top主播榜"},{src:"img/lb4.png",title:"咸菜鱼青衫_"},{src:"img/lb5.png",title:"咸菜鱼青衫_"},{src:"img/lb6.png",title:"【猫耳LIVE】你说的都对 第 3 季"},{src:"img/lb1.jpg",title:"咸菜鱼青衫_"}]
	
	$.each(lbt_list,function(i,e){
		$("<li></li>").html('<img src="'+e.src+'"><span class="banner-title">'+e.title+'</span>').appendTo($(".lbt"))
	
	})
	
	// 轮播图
	var i=0;
	function Banner(t){
		if(t){
			i=i+t;
		}
		if(i==7){
			$(".lbt").stop().animate({"margin-left":"0px"},0);
			i=1;
		}
		if(i==-1){
			$(".lbt").stop().animate({"margin-left":"634px"},0);
			i=5;
		}
		$(".lbt").stop().animate({"margin-left":-634*i+"px"},1000);
		// $(".dot").$("#cricle>li").eq(i%6).css("background","#f60").siblings().css("background","rgba(255,255,0,0.4)");
		$(".dot").eq(i%6).addClass("active").siblings().removeClass("active");
	}
	var timer=setInterval(Banner,4000,1);
	$(".lbt").hover(function(){
		clearInterval(timer)
	},function(){
		timer=setInterval(Banner,4000,1);
	})
	// 小圆点点击
	
	$(".dot").click(function(){
		
		if(i==6){
			i=0;
			$("#lbt").stop().animate({"left":"0px"},0);
			
		}else{
			i=$(this).index();
		}
		Banner();
	})
	
	
	var obj=$.ajax({
		type:"get",
		url:"list.json",
		async:false,
		success:function(response,status,xhr){
			console.log(response)
		}
		
	})

	function Recommend(obj){
		this.src=obj.src,
		this.name=obj.name,
		this.creator=obj.creator,
		this.score=obj.score
	}
	Recommend.prototype={
		init:function(e){
			$('<div class="live-card"></div>').html('<a href=""><img src='+this.src+'></a>\
						<div class="room-intro">\
							<a href="" class="room-name">'+this.name+'</a>\
							<a href="" class="room-creator">'+this.creator+'</a>\
							<span class="room-score">'+this.score+'</span>\
						</div>').appendTo($('.live_card_wrap1'))
	
	},
		init2:function(e){
			$('<div class="live-card"></div>').html('<a href="" ><img src='+this.src+'></a>\
						<div class="room-intro">\
							<a href="" class="room-name">'+this.name+'</a>\
							<a href="" class="room-creator">'+this.creator+'</a>\
							<span class="room-score">'+this.score+'</span>\
						</div>').appendTo($('.live_card_wrap2'));
		}
	}

	$.each(obj.responseJSON.data1,function(i,e){
		// console.log(obj.responseJSON.data);
		var rec=new Recommend(e);
		rec.init();
	})
	$.each(obj.responseJSON.data2,function(i,e){
		// console.log(obj.responseJSON.data);
		var rec=new Recommend(e);
		rec.init2();
	})
	
	// 推荐点击切换
	
	$(".prev").click(function(){
		$(".live-wrap").toggleClass("marLeft");
	
	})
	
	$(".next").click(function(){
		$(".live-wrap").toggleClass("marLeft");
		
	})
	
	// 切换滑入变色
	
	$(".live-card").hover(function(){
		$(this).children("div").children().eq(0).css("color","red")
	},function(){
		$(this).children("div").children().eq(0).css("color","black")
	})
	
	// $(".home-online-live>.live-card>a").hover(function(){
	// 	console.log($(this).children("a").children("p"))
	// 	$(this).children("p").eq(0).css("color","red")
	// },function(){
	// 	$(this).children("div").children().eq(0).css("color","black")
	// })
	
	
	
	// 在线直播
	var obj1=$.ajax({
		type:"get",
		url:"list.json",
		async:false,
		success:function(response,status,xhr){
			console.log(response)
		}
		
	})
	function Online(obj1){
		this.src=obj1.src,
		this.creator=obj1.creator,
		this.score=obj1.score
		this.name=obj1.name,
		this.desc=obj1.desc
	}
	
	Online.prototype={
		init:function(){
			$('<div class="live-card"></div>').html('<a href="">\
							<div class="online_img">\
								<img src="'+this.src+'" >\
								<div class="room-intro">\
									<span class="room-creator">'+this.creator+'</span>\
									<span class="room-score online_score">'+this.score+'</span>\</div></div>\
							<p class="room-name">'+this.name+'</p></a><p class="room-desc">'+this.desc+'</p>').appendTo($(".home-online-live"))
		}
	}
	
	
	
	function Load(){
		$.each(obj1.responseJSON.online,function(i,e){
			var online=new Online(e);
			online.init();
		})
		$(window).scroll(function () {
		    var scrollTop = $(this).scrollTop();
		    var scrollHeight = $(document).height();
		    var windowHeight = $(this).height();
		    if (scrollTop + windowHeight + 10 >= scrollHeight) {
				$('.act_w').show();	
				console.log($(this).scrollTop());
				var t = $(this).scrollTop();
				$('body,html').animate({'scrollTop':t+200},100);
				// $('<li style="border: none;"></li>').html('<img src="img/act_more.gif" alt=""  style="width: 70px; height: 70px;margin-left:50%; "/>').appendTo($("#act_ul")).delay(500).hide(0);
				var timer=setTimeout(function(){
					$.each(obj.responseJSON.online,function(i,e){
						var online=new Online(e);
						online.init();
					})
					$('.act_w').hide()
				},1000)
				
				
		    }
		});
	}
	Load();
	

	
	
})

